/*
package com.manger.utils;

import com.aspose.cells.PdfSaveOptions;
import com.aspose.cells.Workbook;
import com.aspose.slides.Presentation;
import com.aspose.words.Document;
import com.aspose.words.License;
import com.aspose.words.SaveFormat;

import java.io.*;
import java.util.Arrays;

public class File2PdfUtils {

    //doc,dox,xls, xlxs,ppt, pptx ，文本格式
    private static String[] fileSuffix = {".doc",".docx",".xls",".xlsx",".ppt",".pptx",".txt"};

    private static String licenseStr =
            "<License>\n" +
                    "  <Data>\n" +
                    "    <Products>\n" +
                    "      <Product>Aspose.Total for Java</Product>\n" +
                    "      <Product>Aspose.Words for Java</Product>\n" +
                    "      <Product>Aspose.Pdf for Java</Product>\n" +
                    "    </Products>\n" +
                    "    <EditionType>Enterprise</EditionType>\n" +
                    "    <SubscriptionExpiry>20991231</SubscriptionExpiry>\n" +
                    "    <LicenseExpiry>20991231</LicenseExpiry>\n" +
                    "    <SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>\n" +
                    "  </Data>\n" +
                    "  <Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature>\n" +
                    "</License>";


    private static void excelLicense() throws Exception {
        InputStream license = new ByteArrayInputStream(licenseStr.getBytes("UTF-8"));
        com.aspose.cells.License excelLicense = new com.aspose.cells.License();
        excelLicense.setLicense(license);
    }

    private static void pptLicense() throws Exception {
        InputStream license = new ByteArrayInputStream(licenseStr.getBytes("UTF-8"));
        com.aspose.slides.License ppt = new com.aspose.slides.License();
        ppt.setLicense(license);
    }

    private static void wordLicense() throws Exception {
        InputStream license = new ByteArrayInputStream(licenseStr.getBytes("UTF-8"));
        License asposeLic = new License();
        asposeLic.setLicense(license);
    }

    private static void excel2pdf(String filePath, String pdfFilePath){
        try{
            excelLicense();
            File pdfFile = new File(pdfFilePath);// 输出路径
            com.aspose.cells.Workbook wb = new Workbook(filePath);
            FileOutputStream fileOS = new FileOutputStream(pdfFile);

            PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
            pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);

            wb.save(fileOS,pdfSaveOptions);
            fileOS.close();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static void ppt2Pdf(String filePath, String pdfFilePath) {
        try {
            pptLicense();
            InputStream slides = new FileInputStream(filePath);
            Presentation pres = new Presentation(slides);
            File pdfFile = new File(pdfFilePath);
            FileOutputStream fileOS = new FileOutputStream(pdfFile);
            pres.save(fileOS, com.aspose.slides.SaveFormat.Pdf);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void word2Pdf(String filePath, String pdfFilePath) {
        FileOutputStream fileOS = null;

        try {
            wordLicense();
            Document doc = new Document(filePath);
            fileOS = new FileOutputStream(new File(pdfFilePath));
            // 保存转换的pdf文件
            doc.save(fileOS, SaveFormat.PDF);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (fileOS != null) {
                    fileOS.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static boolean canConvert(String fileName){
        for(String suffix:fileSuffix){
            if(fileName.toLowerCase().endsWith(suffix)){
                return true;
            }
        }
        return false;
    }

    public static String getSuffix(){
        return  String.join(",",Arrays.asList(fileSuffix));
    }

    */
/**
     * 可以将doc,dox,xls, xlxs,ppt, pptx和文本格式的文件转为pdf
     * windows, linux 均可以使用
     *
     * **//*

    public static boolean file2Pdf(String resourcePath,String pdfTargetPath) throws Exception {
        String suffix = resourcePath.substring(resourcePath.lastIndexOf(".") + 1, resourcePath.length());
        File file = new File(resourcePath);

        if (!file.exists()) {
            return false;
        }

        file = new File(pdfTargetPath);
        if(file.exists()){
            file.delete();
        }

        try {

            if ("doc".equals(suffix) || "docx".equals(suffix)) {
                File2PdfUtils.word2Pdf(resourcePath, pdfTargetPath);
            } else if ("xls".equals(suffix) || "xlsx".equals(suffix)) {
                File2PdfUtils.excel2pdf(resourcePath, pdfTargetPath);
            } else if ("ppt".equals(suffix) || "pptx".equals(suffix)) {
                File2PdfUtils.ppt2Pdf(resourcePath, pdfTargetPath);
            }
            return true;
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();

        }
        return false;
    }
    public static void main(String[] args) throws Exception {
        // word2Pdf("C:\\Users\\liuhj\\Desktop\\项目管理软件技术指标3.doc", "C:\\Users\\liuhj\\Desktop\\tttt.pdf");
       // ppt2Pdf("C:\\Users\\liuhj\\Desktop\\新建PPTX 演示文稿.pptx", "C:\\Users\\liuhj\\Desktop\\t.pdf");
        // excel2pdf("C:\\Users\\liuhj\\Desktop\\新建XLSX 工作表.xls", "C:\\Users\\liuhj\\Desktop\\dddd.pdf");

//        InputStream license = new ByteArrayInputStream(licenseStr.getBytes("UTF-8"));
//        License asposeLic = new License();
//        asposeLic.setLicense(license);
//        Diagram diagram = new Diagram("C:\\Users\\liuhj\\Desktop\\控制软件1.vsdx");
//        diagram.save("C:\\Users\\liuhj\\Desktop\\Diagram.pdf", SaveFileFormat.PDF);

      */
/*  String filePath = "C:\\Users\\liuhj\\Desktop\\控制软件1.vsdx";
        File file = new File(filePath);
        XmlVisioDocument xmlVisioDocument = new XmlVisioDocument(new FileInputStream(file));
        Collection<XDGFPage> pages = xmlVisioDocument.getPages();
        Iterator<XDGFPage> iterator = pages.iterator();
        //存储所有连线起点的集合
        List<String> startLine = new ArrayList<>();
        //存储所有连线起点的集合
        List<String> endLine = new ArrayList<>();
        //存储所有形状id和文字的集合
        HashMap<String, String> idAndName = new HashMap<>();
        //存储所有形状id和样式的集合
        HashMap<String, String> idAndStyle = new HashMap<>();
        //存储所有形状id和宽高的集合
        HashMap<String, String> idAndSize = new HashMap<>();
        while (iterator.hasNext()) {
            XDGFPage xdgfPage = iterator.next();
            XDGFPageContents content = xdgfPage.getContent();

            //所有包含文字的形状节点
            Collection<XDGFShape> shapes = content.getShapes();
            Iterator<XDGFShape> iterator1 = shapes.iterator();


            while (iterator1.hasNext()) {
                XDGFShape xdgfShape = iterator1.next();
                if (xdgfShape.hasText() && !xdgfShape.getText().getTextContent().equals("")) {
                    //存储文字
                    idAndName.put(Long.toString(xdgfShape.getID()), xdgfShape.getTextAsString());
                    //存储形状类型

                    idAndStyle.put(Long.toString(xdgfShape.getID()), xdgfShape.getName());
                    //存储形状数据,xml结构中*100为业务需要
                    idAndSize.put(Long.toString(xdgfShape.getID()), " <style x=\"" + Math.round(xdgfShape.getPinX() * 100) +
                            "\" y=\"" + Math.round(xdgfShape.getPinY() * 100) +
                            "\" width=\"" + Math.round(xdgfShape.getWidth() * 100) +
                            "\" height=\"" + Math.round(xdgfShape.getHeight() * 100) +
                            "\" as=\"style\"/>");
                }
            }
        }*//*

//        FileInputStream fis = new FileInputStream("C:\\\\Users\\\\liuhj\\\\Desktop\\\\控制软件1.vsdx");
//        POIFSFileSystem poifs = new POIFSFileSystem(fis);
//        HDGFDiagram diagram = new HDGFDiagram(poifs.getRoot());
//        VisioTextExtractor extractor = new VisioTextExtractor(diagram);
//        System.out.println(extractor.getText());

        String filePath = "E:\\360MoveData\\Users\\liuhj\\Desktop\\2024-03-12律所会议纪要.txt";
        String path = "E:\\360MoveData\\Users\\liuhj\\Desktop\\t.pdf";

    }
}
*/
